﻿using RAP.Framework.Libary.Utils;

namespace RAP.Framework.Libary.DomTemplateBuilder.Element.Conditional
{
	/// <summary>
	/// 条件节点基类
	/// </summary>
	public abstract class ConditionalBase : PropertyElement, IConditionalElement
    {
        /// <summary>
        /// “否则”分支
        /// </summary>
		public virtual Else Else
        { 
            get; 
            set; 
        }

		protected ConditionJoinTypes _joinType = ConditionJoinTypes.None;
		/// <summary>
		/// 条件连接方式（Or、And）
		/// </summary>
		public virtual ConditionJoinTypes JoinType
		{
			get
			{
				if ( _joinType == ConditionJoinTypes.None )
				{
					_joinType = this.ToEnumValue<ConditionJoinTypes> ( "JoinType", ConditionJoinTypes.Or );
				}
				return _joinType;
			}
			set
			{
				_joinType = ConditionJoinTypes.None;
				this[ "JoinType" ] = value.GetNames ( "None" );
			}
		}
    }
}
